package com.battery.controller;

import com.battery.pojo.Order;
import com.battery.service.OrderService;
import com.battery.util.result.Result;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

public class OrderController {
    @Autowired
     OrderService orderService;

    @PostMapping("/insertOrder")
    @ApiOperation("添加租借订单")
    public Result insertOrder(@RequestBody @ApiParam(name="租借订单对象",value="传入json格式",required=true) Order order) {
        return orderService.addOrder(order);
    }

    @PutMapping("/modifyOrder")
    @ApiOperation("根据租借订单id更新租借订单")
    public Result modifyOrderById(@RequestBody @ApiParam(name="租借订单对象",value="传入json格式",required=true) Order Order) {
        return orderService.modifyOrder(Order);
    }

    @DeleteMapping("/dropOrder/{order_id}")
    @ApiOperation("根据租借订单id删除商铺")
    public Result dropOrderById(@RequestBody @ApiParam(name="租借订单id",required=true) int order_id) {
        return orderService.dropOrder(order_id);
    }
    @GetMapping("/queryUserOrder/{user_id}")
    @ApiOperation("根据用户id查询租借订单")
    public Result queryOrderByUserId(@ApiParam(name="用户id",required=true)int user_id) {
        return orderService.queryAllUserOrder(user_id);
    }
    @GetMapping("/queryMerOrder/{mer_id}")
    @ApiOperation("根据商铺id查询租借订单")
    public Result queryOrderByMerId(@ApiParam(name="租借订单id",required=true)int mer_id) {
        return orderService.queryAllMerOrder(mer_id);
    }
    @GetMapping("/queryAllOrder")
    @ApiOperation("查询所有租借订单")
    public Result queryOrderById() {
        return orderService.queryAllOrder();
    }
}
